#!/usr/bin/env python
#coding:utf-8
import cgitb
import cgi
cgitb.enable()
form = cgi.FieldStorage()
text = form.getvalue('text', open('data.dat').read())
f = open('data.dat', 'w')
f.write(text)
f.close()

print """Content-type: text/html

<html>
<head>
<title>A Simple editor</title>
</head>
<body>"""
print "<center>"
print "<h1>欢迎来到我的个人Wiki</h1>"
print """<p><a href="index.py">回到首页</a> | <a href="simple_edit.py">编辑</a></p>"""
print "<hr />"
print "</center>"
print """
<form action="simple_edit.py" method='POST'>
<textarea rows="10" cols="100" name="text">%s</textarea><br />
<input type="submit" />
</form>
</body>
</html>""" % text
